//nav 切换
$(".nav span").click(function(){
    var index = $(this).index();
    $(this).addClass("active").siblings().removeClass("active");
    console.log($(".panelWrap .panel" + index));
    $(".panelWrap .panel" + index).css({"display":"block"}).siblings().css({"display":"none"});
});



//性别
var data1 = [ {
    text:'男', 
    value:1
  },  {
    text:'女', 
    value:0
  }
]; 
var  picker1El = document.getElementById("gender"); 
var picker1 = new Picker( {
  data:[data1]
}); 

picker1.on('picker.select', function (selectedVal, selectedIndex) {
  picker1El.value = data1[selectedIndex[0]].text; 
}); 
picker1El.addEventListener('click', function () {
  picker1.show(); 
}); 

// 与患者关系
var data2 = [ {
  text:'其他', 
  value:0
},  {
  text:'父子', 
  value:1
},  {
  text:'母子', 
  value:1
},  {
  text:'本人', 
  value:1
},  {
  text:'父女', 
  value:1
},  {
  text:'母女', 
  value:1
},  {
  text:'夫妻', 
  value:1
}
]; 
var  picker2El = document.getElementById("relation"); 
var picker2 = new Picker( {
  data:[data2]
}); 

picker2.on('picker.select', function (selectedVal, selectedIndex) {
  picker2El.value = data2[selectedIndex[0]].text; 
}); 
picker2El.addEventListener('click', function () {
  picker2.show(); 
}); 

// 选择日期
$(function () {
  var currYear = (new Date()).getFullYear(); 	
  var opt =  {}; 
  opt.date =  {preset:'date'}; 
  opt.datetime =  {preset:'datetime'}; 
  opt.time =  {preset:'time'}; 
  opt.default =  {
      theme:'android-ics light', //皮肤样式
display:'modal', //显示方式 
mode:'scroller', //日期选择模式
dateFormat:'yyyy-mm-dd', 
      lang:'zh', 
      showNow:true, 
      nowText:"今天", 
      startYear:currYear - 100, //开始年份
endYear:currYear  //结束年份
  }; 

  $("#USER_AGE").mobiscroll($.extend(opt['date'], opt['default'])); 

}); 
$(".info input").click(function () {
    $(".panel0").css( {"paddingBottom":"4rem"}); 
}); 



var handleArr = [$("#allergy"),$("#smoking"),$("#driving"),$("#eating"),$("#sleepping"),$("#pee"),$("#narcotic")];
var len = handleArr.length;
for(var i = 0; i < len; i++){
  handleArr[i].click(function () {

    var flag = $(this).siblings(".switch").attr("flag");
    if (flag == "false") {
      $(this).siblings(".switch").children("i").addClass("active"); 
        $(this).siblings(".switch").addClass("active").attr("flag", "true");
    }else{
      $(this).siblings(".switch").children("i").removeClass("active"); 
        $(this).siblings(".switch").removeClass("active").attr("flag", "false");
    }
  }); 
}